package com.sc.controller;

import com.sc.common.pojo.CommonResult;
import com.sc.common.pojo.EasyUiDataGridResult;
import com.sc.service.ItemParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by sc on 2017/10/16.
 */
@Controller
@RequestMapping("/item/param")
public class ItemParamController {

    @Autowired
    private ItemParamService itemParamService;

    @RequestMapping(value = "/list")
    @ResponseBody
    public EasyUiDataGridResult getParamList(Integer page, Integer rows){
        EasyUiDataGridResult result =  itemParamService.getParamList(page,rows);
        return result;
    }

    @RequestMapping(value = "/{id}/save",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult save(@PathVariable("id") Long cid,String paramData){
        return itemParamService.save(cid,paramData);
    }


    @RequestMapping("/{cid}/itemcatid/query")
    @ResponseBody
    public CommonResult queryDiff(@PathVariable("cid") Long catId){
        return itemParamService.queryDiffById(catId);
    }

    @RequestMapping("/cid/{cid}")
    @ResponseBody
    public CommonResult query(@PathVariable("cid") Long catId){
        return itemParamService.queryDiffById(catId);
    }

}
